package com.test.listview;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.SimpleAdapter;

public class SimpleAdapterActivity extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SimpleAdapter adapter = new SimpleAdapter(this, getData(),
                R.layout.simple_adapter_item, new String[] { "img", "title", "info" },
                new int[] { R.id.img, R.id.title, R.id.info });
        setListAdapter(adapter);
    }

    private List<Map<String, Object>> getData() {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "小宗");
        map.put("info", "电台DJ");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "貂蝉");
        map.put("info", "四大美女");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "奶茶");
        map.put("info", "清纯妹妹");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "大黄");
        map.put("info", "是小狗");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "hello");
        map.put("info", "every thing");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "world");
        map.put("info", "hello world");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "1");
        map.put("info", "1111");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "2");
        map.put("info", "222222222");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "3");
        map.put("info", "3333333333");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "4");
        map.put("info", "444444444");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "5");
        map.put("info", "5555555555");
        list.add(map);

        map = new HashMap<String, Object>();
        map.put("img", R.drawable.portraita);
        map.put("title", "6");
        map.put("info", "6666666666");
        list.add(map);

        return list;
    }
}